$(function() {
    var contextPath = function() {
        return  "/" + location.pathname.split("/")[1];
    }

    function getValue(name){
        var str=window.location.search;
        if (str.indexOf(name)!=-1){
            var pos_start=str.indexOf(name)+name.length+1;
            var pos_end=str.indexOf("&",pos_start);
            if (pos_end==-1){
                return str.substring(pos_start);
            } else {
                return str.substring(pos_start,pos_end);
            }
        } else {
            return "";
        }
    }

	getCollegeContext();
	
	function getCollegeContext(e) {
		$.ajax({
			url : contextPath()+"/airuc/getcollegebyid?collegeid=11",//collegeid=11 即为运营培训系统
			type : "get",
			dataType : "json",
			success : function(data) {
				if (data.success) {
					createPage(data.college);
				}
			}
		});
	}
	
	function createPage(data) {
		var html = '';
		html += "<div class='swiper-container' data-space-between='10' data-pagination='.swiper-pagination' data-autoplay='1000'>"
				+ "<div class='swiper-wrapper'>"
				+ "<div class='swiper-slide'><img src='//gqianniu.alicdn.com/bao/uploaded/i4//tfscom/i1/TB1n3rZHFXXXXX9XFXXXXXXXXXX_!!0-item_pic.jpg_320x320q60.jpg' alt=''></div>"
				+ "<div class='swiper-slide'><img src='//gqianniu.alicdn.com/bao/uploaded/i4//tfscom/i4/TB10rkPGVXXXXXGapXXXXXXXXXX_!!0-item_pic.jpg_320x320q60.jpg' alt=''></div>"
				+ "<div class='swiper-slide'><img src='//gqianniu.alicdn.com/bao/uploaded/i4//tfscom/i1/TB1kQI3HpXXXXbSXFXXXXXXXXXX_!!0-item_pic.jpg_320x320q60.jpg' alt=''></div>"
				+ "<div class='swiper-slide'><img src='images/classimg/swiper2.jpg' width='100'  height='100' alt=''></div>"
				+ "	</div>"
				+ "</div>";
		data.courseList.map(function(item, index) {
			html += "<div class='weui-panel weui-panel_access'>"
					+ "<div class='weui-panel__hd'><h2>"+item.courseName+"</h2></div>"
					+ "<div class='weui-panel__bd'>";
			item.lessonList.map(function(item1, index1) {
				if (index1<2) {
					//只显示两个课程
					html += "<a href='yylesson.html?lessonid="+item1.lessonID+"' class='weui-media-box weui-media-box_appmsg'>"
		    		+ "<div class='weui-media-box__hd'>"
		    		+ "<img class='weui-media-box__thumb' src='"+item1.lessonImg+"'>"
		    		+ "</div>"
		    		+ "<div class='weui-media-box__bd'>"
		    		+ "<h4 class='weui-media-box__title'>"+item1.lessonName+"</h4>"
		    		+ "<p class='weui-media-box__desc'>"+item1.lessonDesc+"</p>"
		    		+ "</div>"
		    		+ "</a>";
				}
			});
			html += "</div>";
			html += "<div class='weui-panel__ft'>"
					+ "<a href='yycourse.html?courseid="+item.courseID+"' class='weui-cell weui-cell_access weui-cell_link'>"
					+ "<div class='weui-cell__bd'>查看更多</div>"
					+ "<span class='weui-cell__ft'></span>"
					+ "</a>"
					+ "</div>";
			html += "</div>";
		});
		html += "<div class='weui-loadmore weui-loadmore_line'><span class='weui-loadmore__tips'>我是有底线的</span></div>"
			+ "<div class='weui-loadmore weui-loadmore_line weui-loadmore_dot'><span class='weui-loadmore__tips'></span></div>";
		$('#tab1').html(html);
	}

    FastClick.attach(document.body);
    $(".swiper-container").swiper(config);	
    
});